const {
	http
} = uni.$u
const config = {
	header: {
		"X-SS-API-KEY": "55b3c71f-ec7e-4728-9564-ddb17d16d1f8",
		"Content-Type": "application/json",
		siteServer: true

	}
}
// 、
export const getContent = params => http.get('/API/HomePage/GetChangShangInfoByID',params)
export const changeContent = params => http.post('/API/User/PostUpdateZhanShangContent',params)
export const changeLogo = prarms => http.post('/API/User/PostUploadZhanShangLogo',params)
export const getIndexList = params =>http.post('/API/HomePage/PostGetZhanShangList',params)
export const getCompanyDetail = params => http.get('/API/HomePage/GetChangShangInfoByID',params)
export const getPicss = params => http.post('/API/ZhanPin/PostGetZhanTaiPictureList',params)
export const delPic = params => http.get('/API/User/GetDeletePictures',params)
export const getPics = (params) => http.post('/API/HomePage/PostGetOneChangShangPictureList',params)
export const getYuYueList = (params) => http.get('/API/User/GetUserYuYueList', params)
export const getCompanyPic = (params) => http.post('/API/HomePage/PostGetOneChangShangPictureList', params)
export const yuyue = (params) => http.post('/API/User/PostZhiBoYuYue', params)
export const getCompanyPro = (params) => http.post('/API/HomePage/PostGetOneChangShangZhanPingList', params)
export const comment = (params) => http.post('API/User/PostSubmiteMessage', params)
export const getCompanyComment = (params) => http.post('/API/User/PostGetChangShangPageMessagelist', params)
export const getOwnComment = (params) => http.post('/API/User/PostGetUserMessagelist', params)
export const renzheng = (params) => http.post('/API/User/PostRenZheng', params)
export const regist = (params) => http.post('/API/User/PostUserRegist', params)
export const getUserInfo = (params) => http.post('/API/WeiXin/PostReturnWeiXinUserInfo', params)
export const isRegist = (params) => http.get('/API/User/GetCheckIsRegisted', params)
export const getList = (params) => http.post('/api/v1/contents', params, config)
export const getInofs = (params) => http.post('/api/v1/contents', params, config)
export const getIndex = (params) => http.get('/API/HomePage/GetHomepageDB')
export const getZhuanTi = (params) => http.get(
	'/api/v1/channels/1/9/?siteId=12&channelId=15&apiKey=55b3c71f-ec7e-4728-9564-ddb17d16d1f8', {}, config)
export const getNavs1 = (params) => http.get(
	'/api/v1/channels/1/9/?siteId=12&channelId=13&apiKey=55b3c71f-ec7e-4728-9564-ddb17d16d1f8', {}, config)
export const getNavs4 = (params) => http.post('/api/v1/contents', params, config)
export const getNavs6 = (params) => http.post('/API/HomePage/PostGetZhanShangList', params)
export const getNavs7 = (params) => http.post('/API/ZhanPin/PostGetZhanPinList', params)
export const getNavs7Types = (params) => http.get('/API/ZhanPin/GetZhanPinTypeList', params)
export const getNavs8 = (params) => http.post('/API/User/PostGetZhiBoList', params)

// 获取菜单
export const getOpenId = (params) => http.post('/API/WeiXin/PostReturnOpenID', params)
export const submitInfo = (params) => http.post('/API/User/PostBaomingInfo', params)
export const getMeting = (params) => http.get('/API/User/GetHuiyiList', params)
export const submitInfo2 = (params) => http.post('/API/User/PostCanhuiBaoming', params)
export const getCode = () => {
	let isWXBrowser = isWXBrowserFn();
	if (isWXBrowser) {
		let code = getUrlCode("code");
		if (code) {
			return code
		} else {
			getWeChatCode(); //微信授权
		}
	} else {
		alert('请使用微信进入！')
	}
}

function getWeChatCode() {
	let local = encodeURIComponent(window.location.href); //获取当前页面地址作为回调地址
	let appid = 'wxfd037bad91d737c0'
	window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid +
		"&redirect_uri=" + local +
		"&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect"
}

function getUrlCode(name) {
	return (
		decodeURIComponent(
			(new RegExp("[?|&]" + name + "=" + "([^&;]+?)(&|#|;|$)").exec(
				location.href
			) || [, ""])[1].replace(/\+/g, "%20")
		) || null
	);
}
//判断是否是微信内置的浏览器
function isWXBrowserFn() {
	return (
		String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) ===
		"micromessenger"
	);
}